package com.jacklin.converter;

import com.jacklin.DTO.OrderDTO;
import com.jacklin.entity.OrderMaster;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * OrderMaster和OrderDTO的转换类
 * @Author:JackLin
 * @Create 2019/3/30 9:37
 */

public class OrderMaster2OrderDTOConverter {

    public static OrderDTO convert(OrderMaster orderMaster){

        /**
         * 这里的转换思想可以使用BeanUtils.copyProperties()的方法来实现
         */
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster, orderDTO);
        return orderDTO;
    }

    //使用lambda表达式--理解理解？？？
    public static List<OrderDTO> convert(List<OrderMaster> orderMasterList){
        return orderMasterList.stream().map(e -> convert(e)).collect(Collectors.toList());
    }

}
